package tree;

import java.util.List;


public class MaximumDepthOfNAryTree559 {
    class Node {
        public int val;
        public List<Node> children;

        public Node() {}

        public Node(int _val) {
            val = _val;
        }

        public Node(int _val, List<Node> _children) {
            val = _val;
            children = _children;
        }
    }
    public int maxDepth(Node root) {
        if(root==null){
            return 0;
        }

        int max = 0;
        List<Node>  childrens  = root.children;
        for (Node n :childrens
                ) {
            int depth = maxDepth(n);
            max = max>depth?max:depth;
        }
        return max+1;
    }
}
